// 这个是用来干嘛的 就是给表单提供数据的
import { reactive, ref } from 'vue'
import { addBaseLine } from '@/api/test/testModel'
import useInstance from '@/hooks/useInstance';
import { EditType } from '@/type/BaseEnum'
import { AddBaseLineApi } from '@/api/test/test'
export default function useBaseModel(getBaseline?,getAuditList?,searchParams?) {
    const { global, proxy } = useInstance()
    const addBaseLineChild = ref<{ show: (type: string, row?: any) => void }>()
    const rules = reactive({
        taskBaseline: [{
            required: true,
            message: '请填写基线名称',
            trigger: 'blur',
        }],

    })
    const dialogModel = reactive<addBaseLine>({
        taskBaseline: '',
        taskId: '',
    })
    const baseAddBtn = (id) => {
        // dialogModel.taskId = id

        addBaseLineChild?.value?.show(EditType.ADD, id)
    }
    const save = async (row) => {
        const res = await AddBaseLineApi(row)
        if (res.code === 200) {
            console.log(res);
            global.$message({ message: '新增成功', type: 'success' })
            getBaseline(row.taskId)

            getAuditList(searchParams.id, searchParams.taskBaselineId)
        }
    }
    return {
        rules, dialogModel, addBaseLineChild, baseAddBtn, save
    }
}